/* eslint-disable prettier/prettier */
import { Injectable } from '@nestjs/common';
// import { CreateCommitDto } from './dto/create-commit.dto';
// import { UpdateCommitDto } from './dto/update-commit.dto';
import { InjectModel } from '@nestjs/mongoose';
import { Commit } from './schemas/commit.schema';
import { Model } from 'mongoose';

@Injectable()
export class CommitsService {
  constructor(@InjectModel(Commit.name) private commitModel: Model<Commit>) { }

  // create(createCommitDto: CreateCommitDto) {
  //   return this.commitModel.create(createCommitDto)
  // }

  // findAll() {
  //   return this.commitModel.find().limit(20)
  // }

  async findCommits(id: string) {
    const result = await this.commitModel.find({ commentId: id })
    if (result.length > 0) {
      return {
        code: 200,
        msg: "获取评论成功!",
        data: result
      }
    } else {
      return {
        code: 200,
        msg: "该医生暂无评论!"
      }
    }
  }

  // update(id: number, updateCommitDto: UpdateCommitDto) {
  //   return `This action updates a #${id} commit`;
  // }

  // remove(id: number) {
  //   return `This action removes a #${id} commit`;
  // }
}
